function f_get_mysql_node_info()
{   
    declare fun_name _m _s _c
    fun_name="f_get_mysql_node_info"
    [ -n "${mysql_host}" ] && return 0
    if [ "${mode_opt}x" == "crontab_dropx" ] || [ "${mode_opt}x" == "crontab_taskx" ]
    then
        mysql_port=0
    fi
    timeout ${exe_time} ${mysql_comm_dbadb} -e "select 1" >/dev/null 2>&1 && exe_state="${?}" || exe_state="${?}"
    if [ ${exe_state} -ne 0 ]
    then
        timeout ${exe_time} ${mysql_comm_dbadb} -e "select 1" #>/dev/null 2>&1 && exe_state="${?}" || exe_state="${?}"
        f_logging "$(eval echo ${log_addr}):ERROR" "连接dbadb环境 '${dbadb_host}:${dbadb_port}' 异常" "2" "1"
    fi
    
    for ((_c=0;_c<60;_c++))
    do
        #获取mysql集群的信息, 正常会获取两条记录, 优先选择和master同机房的slave, 用户gh-ost改表检查延迟
        _m="SELECT concat(type,'_',ip) FROM ${t_mysql_rs} WHERE status = 1 AND port = ${mysql_port} order by type" #master
        mysql_host_info=($(timeout ${exe_time} ${mysql_comm_dbadb} -NBe "${_m}" 2>&1|sed '/Using a password/d')) || true
        [ -n "${mysql_host_info}" ] && break
        [ "${mysql_port}x" == "0x" ] && break
        sleep 1
    done

    #将所有slave都获取出来, 用户检查mdl状态, 防止改表过程中产生mdl阻塞了数据库, 如果有mdl则会kill掉空连接
    _s="select ip from ${t_mysql_rs} where status = 1 and port = ${mysql_port} and type = 'slave'"
    mysql_slave_info=($(timeout ${exe_time} ${mysql_comm_dbadb} -NBe "${_s}" 2>&1|sed '/Using a password/d')) || true
 
    if [ "${mode_opt}x" == "crontab_dropx" ] || [ "${mode_opt}x" == "crontab_taskx" ]
    then
        true
    elif [ -z "${mysql_host_info}" ]
    then #mysql_host_info为空表示没有找到master
        f_logging "$(eval echo ${log_addr}):ERROR" "'${dbadb_host}:${dbadb_port}'获取'${mysql_port}'的master ip异常 ] [ ${_m}" "2" "1"
    elif [ -z "${mysql_slave_info}" ]
    then
        f_logging "$(eval echo ${log_addr}):WARN" "'${dbadb_host}:${dbadb_port}'获取'${mysql_port}'的slave ip异常, 这个集群可能是个单点 ] [ ${_m}" "2"
    fi

    mysql_slave_info=($(tr " " "\n" <<< "${mysql_slave_info[@]}"|awk -v port="${mysql_port}" '{print $0":"port}'|tr '\n' ","|sed 's/,$//g'))
    #从dbadb取出的结果赋值给对应的变量
    if [ "${mode_opt}x" == "crontab_dropx" ] || [ "${mode_opt}x" == "crontab_taskx" ]
    then
        true
    elif [ "$(grep -ic "^master_" <<< "${mysql_host_info[0]}")x" == "1x" ]
    then
        mysql_host="${mysql_host_info[0]}"
        mysql_slave_host="${mysql_host_info[1]}"
    elif [ "$(grep -ic "^master_" <<< "${mysql_host_info[1]}")x" == "1x" ]
    then
        mysql_host="${mysql_host_info[1]}"
        mysql_slave_host="${mysql_host_info[0]}"
    else
        f_logging "$(eval echo ${log_addr}):ERROR" "'${dbadb_host}:${dbadb_port}'获取'${mysql_port}'的master ip异常" "2" "1"
    fi
    
    mysql_host="$(awk -F_ '{print $2}' <<< "${mysql_host}")"   #获取master的ip
    return 0
}

